package sctu.edu.java.year2016.team06.yuweimei.day20160522.chapter5_3;

/**编写Java程序，创建二维数组arr[][],将二维数组中所有元素的和输出。
 * Created by asus on 2016/5/23.
 */
public class chapter5_3 {
    public static void main(String[]args){
        int a[][]={{1,2},{4,7},{8,9}};
        int sum=0;
        System.out.println("二维数组的元素有：");
        for (int i=0;i<a.length;i++) {
            for (int j = 0; j < a[i].length; j++) {
                System.out.print(a[i][j] + "\t");
                sum = sum + a[i][j];
            }
            System.out.println("");
        }
        System.out.println("\n二维数组的和为："+sum);
    }
}
